<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: dom   dom.js  (YUI Library)</title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" />
	<link rel="stylesheet" type="text/css" href="assets/api.css" />

    <script type="text/javascript" src="assets/api-js"></script>
    <script type="text/javascript" src="assets/ac-js"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1><a href="http://developer.yahoo.com/yui/" title="Yahoo! UI Library">Yahoo! UI Library</a></h1>
        <h3>dom&nbsp; <span class="subtitle">3.0.0b1</span></h3>
        <a href="./index.html" title="Yahoo! UI Library">Yahoo! UI Library</a> 
            &gt; <a href="./module_dom.html" title="dom">dom</a>
                
                 &gt; dom.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
<div class="highlight" ><pre><span class="o">(</span><span class="k">function</span><span class="o">(</span><span class="nx">Y</span><span class="o">)</span> <span class="o">{</span>
<span class="c">/** </span>
<span class="c"> * The DOM utility provides a cross-browser abtraction layer</span>
<span class="c"> * normalizing DOM tasks, and adds extra helper functionality</span>
<span class="c"> * for other common tasks. </span>
<span class="c"> * @module dom</span>
<span class="c"> * @submodule dom-base</span>
<span class="c"> *</span>
<span class="c"> */</span>

<span class="c">/**</span>
<span class="c"> * Provides DOM helper methods.</span>
<span class="c"> * @class DOM</span>
<span class="c"> *</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">NODE_TYPE</span> <span class="o">=</span> <span class="s1">&#39;nodeType&#39;</span><span class="o">,</span>
    <span class="nx">OWNER_DOCUMENT</span> <span class="o">=</span> <span class="s1">&#39;ownerDocument&#39;</span><span class="o">,</span>
    <span class="nx">DOCUMENT_ELEMENT</span> <span class="o">=</span> <span class="s1">&#39;documentElement&#39;</span><span class="o">,</span>
    <span class="nx">DEFAULT_VIEW</span> <span class="o">=</span> <span class="s1">&#39;defaultView&#39;</span><span class="o">,</span>
    <span class="nx">PARENT_WINDOW</span> <span class="o">=</span> <span class="s1">&#39;parentWindow&#39;</span><span class="o">,</span>
    <span class="nx">TAG_NAME</span> <span class="o">=</span> <span class="s1">&#39;tagName&#39;</span><span class="o">,</span>
    <span class="nx">PARENT_NODE</span> <span class="o">=</span> <span class="s1">&#39;parentNode&#39;</span><span class="o">,</span>
    <span class="nx">FIRST_CHILD</span> <span class="o">=</span> <span class="s1">&#39;firstChild&#39;</span><span class="o">,</span>
    <span class="nx">LAST_CHILD</span> <span class="o">=</span> <span class="s1">&#39;lastChild&#39;</span><span class="o">,</span>
    <span class="nx">PREVIOUS_SIBLING</span> <span class="o">=</span> <span class="s1">&#39;previousSibling&#39;</span><span class="o">,</span>
    <span class="nx">NEXT_SIBLING</span> <span class="o">=</span> <span class="s1">&#39;nextSibling&#39;</span><span class="o">,</span>
    <span class="nx">CONTAINS</span> <span class="o">=</span> <span class="s1">&#39;contains&#39;</span><span class="o">,</span>
    <span class="nx">COMPARE_DOCUMENT_POSITION</span> <span class="o">=</span> <span class="s1">&#39;compareDocumentPosition&#39;</span><span class="o">,</span>

    <span class="nx">re_tag</span> <span class="o">=</span> <span class="sr">/&lt;([a-z]+)/i</span><span class="o">;</span>

<span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span> <span class="o">=</span> <span class="o">{</span>
    <span class="c">/**</span>
<span class="c">     * Returns the HTMLElement with the given ID (Wrapper for document.getElementById).</span>
<span class="c">     * @method byId         </span>
<span class="c">     * @param {String} id the id attribute </span>
<span class="c">     * @param {Object} doc optional The document to search. Defaults to current document </span>
<span class="c">     * @return {HTMLElement | null} The HTMLElement with the id, or null if none found. </span>
<span class="c">     */</span>
    <span class="nx">byId</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">doc</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">doc</span> <span class="o">=</span> <span class="nx">doc</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">doc</span><span class="o">;</span>
        <span class="c">// TODO: IE Name</span>
<span class="c"></span>        <span class="k">return</span> <span class="nx">doc</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="nx">id</span><span class="o">);</span>
    <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * Returns the text content of the HTMLElement. </span>
<span class="c">     * @method getText         </span>
<span class="c">     * @param {HTMLElement} element The html element. </span>
<span class="c">     * @return {String} The text content of the element (includes text of any descending elements).</span>
<span class="c">     */</span>
    <span class="nx">getText</span><span class="o">:</span> <span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">textContent</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">?</span>
        <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">ret</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">ret</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">textContent</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">return</span> <span class="nx">ret</span> <span class="o">||</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
        <span class="o">}</span> <span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">ret</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">ret</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">innerText</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">return</span> <span class="nx">ret</span> <span class="o">||</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
        <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * Sets the text content of the HTMLElement. </span>
<span class="c">     * @method setText         </span>
<span class="c">     * @param {HTMLElement} element The html element. </span>
<span class="c">     * @param {String} content The content to add. </span>
<span class="c">     */</span>
    <span class="nx">setText</span><span class="o">:</span> <span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">textContent</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">?</span>
        <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">content</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">element</span><span class="o">.</span><span class="nx">textContent</span> <span class="o">=</span> <span class="nx">content</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span> <span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">content</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">element</span><span class="o">.</span><span class="nx">innerText</span> <span class="o">=</span> <span class="nx">content</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">},</span>

<span class="c">// TODO: pull out sugar (rely on _childBy, byAxis, etc)?</span>
<span class="c"></span>    <span class="c">/*</span>
<span class="c">     * Finds the firstChild of the given HTMLElement. </span>
<span class="c">     * @method firstChild</span>
<span class="c">     * @deprecated Use _childBy</span>
<span class="c">     * @param {HTMLElement} element The html element. </span>
<span class="c">     * @param {Function} fn optional An optional boolean test to apply.</span>
<span class="c">     * The optional function is passed the current HTMLElement being tested as its only argument.</span>
<span class="c">     * If no function is given, the first found is returned.</span>
<span class="c">     * @return {HTMLElement | null} The first matching child html element.</span>
<span class="c">     */</span>
    <span class="nx">firstChild</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_childBy</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="nx">fn</span><span class="o">);</span>
    <span class="o">},</span>

    <span class="c">// @deprecated Use _childBy</span>
<span class="c"></span>    <span class="nx">firstChildByTag</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_childBy</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">fn</span><span class="o">);</span>
    <span class="o">},</span>

    <span class="c">/*</span>
<span class="c">     * Finds the lastChild of the given HTMLElement.</span>
<span class="c">     * @method lastChild</span>
<span class="c">     * @deprecated Use _childBy</span>
<span class="c">     * @param {HTMLElement} element The html element.</span>
<span class="c">     * @param {String} tag The tag to search for.</span>
<span class="c">     * @param {Function} fn optional An optional boolean test to apply.</span>
<span class="c">     * The optional function is passed the current HTMLElement being tested as its only argument.</span>
<span class="c">     * If no function is given, the first found is returned.</span>
<span class="c">     * @return {HTMLElement | null} The first matching child html element.</span>
<span class="c">     */</span>
    <span class="nx">lastChild</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_childBy</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
    <span class="o">},</span>

    <span class="c">// @deprecated Use _childBy</span>
<span class="c"></span>    <span class="nx">lastChildByTag</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_childBy</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
    <span class="o">},</span>

    <span class="c">/*</span>
<span class="c">     * Finds all HTMLElement childNodes matching the given tag.</span>
<span class="c">     * @method childrenByTag</span>
<span class="c">     * @deprecated Use Selector</span>
<span class="c">     * @param {HTMLElement} element The html element.</span>
<span class="c">     * @param {String} tag The tag to search for.</span>
<span class="c">     * @param {Function} fn optional An optional boolean test to apply.</span>
<span class="c">     * The optional function is passed the current HTMLElement being tested as its only argument.</span>
<span class="c">     * If no function is given, all children with the given tag are collected.</span>
<span class="c">     * @return {Array} The collection of child elements.</span>
<span class="c">     * TODO: Webkit children.tags() returns grandchildren</span>
<span class="c">     */</span>
    <span class="nx">_childrenByTag</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
        <span class="k">if</span> <span class="o">(</span><span class="nb">document</span><span class="o">[</span><span class="nx">DOCUMENT_ELEMENT</span><span class="o">].</span><span class="nx">children</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">toArray</span><span class="o">)</span> <span class="o">{</span> <span class="c">// TODO: keep toArray option?</span>
<span class="c"></span>                <span class="nx">tag</span> <span class="o">=</span> <span class="o">(</span><span class="nx">tag</span> <span class="o">&amp;&amp;</span> <span class="nx">tag</span> <span class="o">!==</span> <span class="s1">&#39;*&#39;</span><span class="o">)</span> <span class="o">?</span> <span class="nx">tag</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
                <span class="k">var</span> <span class="nx">elements</span> <span class="o">=</span> <span class="o">[],</span>
                    <span class="nx">wrapFn</span> <span class="o">=</span> <span class="nx">fn</span><span class="o">;</span>
                <span class="k">if</span> <span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">if</span> <span class="o">(</span><span class="nx">tag</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">.</span><span class="nx">webkit</span><span class="o">)</span> <span class="o">{</span> <span class="c">// children.tags() broken in safari</span>
<span class="c"></span>                        <span class="nx">elements</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">children</span><span class="o">.</span><span class="nx">tags</span><span class="o">(</span><span class="nx">tag</span><span class="o">);</span>
                    <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">elements</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">children</span><span class="o">;</span>
                        <span class="k">if</span> <span class="o">(</span><span class="nx">tag</span><span class="o">)</span> <span class="o">{</span>
                            <span class="nx">wrapFn</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
                                <span class="k">return</span> <span class="nx">el</span><span class="o">[</span><span class="nx">TAG_NAME</span><span class="o">].</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">===</span> <span class="nx">tag</span> <span class="o">&amp;&amp;</span> <span class="o">(!</span><span class="nx">fn</span> <span class="o">||</span> <span class="nx">fn</span><span class="o">(</span><span class="nx">el</span><span class="o">));</span>
                            <span class="o">};</span>
                        <span class="o">}</span>
                    <span class="o">}</span>

                    <span class="nx">elements</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">filterElementsBy</span><span class="o">(</span><span class="nx">elements</span><span class="o">,</span> <span class="nx">wrapFn</span><span class="o">);</span>
                <span class="o">}</span>

                <span class="k">return</span> <span class="nx">elements</span><span class="o">;</span>
            <span class="o">};</span>
        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
            <span class="k">return</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">tag</span> <span class="o">=</span> <span class="o">(</span><span class="nx">tag</span> <span class="o">&amp;&amp;</span> <span class="nx">tag</span> <span class="o">!==</span> <span class="s1">&#39;*&#39;</span><span class="o">)</span> <span class="o">?</span> <span class="nx">tag</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
                <span class="k">var</span> <span class="nx">elements</span> <span class="o">=</span> <span class="o">[],</span>
                    <span class="nx">wrapFn</span> <span class="o">=</span> <span class="nx">fn</span><span class="o">;</span>

                <span class="k">if</span> <span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">elements</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">childNodes</span><span class="o">;</span> 
                    <span class="k">if</span> <span class="o">(</span><span class="nx">tag</span><span class="o">)</span> <span class="o">{</span> <span class="c">// wrap fn and add tag test TODO: allow tag in filterElementsBy?</span>
<span class="c"></span>                        <span class="nx">wrapFn</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">return</span> <span class="nx">el</span><span class="o">[</span><span class="nx">TAG_NAME</span><span class="o">].</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">===</span> <span class="nx">tag</span> <span class="o">&amp;&amp;</span> <span class="o">(!</span><span class="nx">fn</span> <span class="o">||</span> <span class="nx">fn</span><span class="o">(</span><span class="nx">el</span><span class="o">));</span>
                        <span class="o">};</span>
                    <span class="o">}</span>

                    <span class="nx">elements</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">filterElementsBy</span><span class="o">(</span><span class="nx">elements</span><span class="o">,</span> <span class="nx">wrapFn</span><span class="o">);</span>
                <span class="o">}</span>
                <span class="k">return</span> <span class="nx">elements</span><span class="o">;</span>
            <span class="o">};</span>
        <span class="o">}</span>
    <span class="o">}(),</span>

    <span class="c">/*</span>
<span class="c">     * Finds all HTMLElement childNodes.</span>
<span class="c">     * @method children</span>
<span class="c">     * @deprecated Use Selector</span>
<span class="c">     * @param {HTMLElement} element The html element.</span>
<span class="c">     * @param {Function} fn optional An optional boolean test to apply.</span>
<span class="c">     * The optional function is passed the current HTMLElement being tested as its only argument.</span>
<span class="c">     * If no function is given, all children are collected.</span>
<span class="c">     * @return {Array} The collection of child elements.</span>
<span class="c">     */</span>
    <span class="nx">children</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_childrenByTag</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="nx">fn</span><span class="o">);</span>
    <span class="o">},</span>

    <span class="c">/*</span>
<span class="c">     * Finds the previous sibling of the element.</span>
<span class="c">     * @method previous</span>
<span class="c">     * @deprecated Use elementByAxis</span>
<span class="c">     * @param {HTMLElement} element The html element.</span>
<span class="c">     * @param {Function} fn optional An optional boolean test to apply.</span>
<span class="c">     * The optional function is passed the current DOM node being tested as its only argument.</span>
<span class="c">     * If no function is given, the first sibling is returned.</span>
<span class="c">     * @param {Boolean} all optional Whether all node types should be scanned, or just element nodes.</span>
<span class="c">     * @return {HTMLElement | null} The matching DOM node or null if none found. </span>
<span class="c">     */</span>
    <span class="nx">previous</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">all</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">elementByAxis</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">PREVIOUS_SIBLING</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">all</span><span class="o">);</span>
    <span class="o">},</span>

    <span class="c">/*</span>
<span class="c">     * Finds the next sibling of the element.</span>
<span class="c">     * @method next</span>
<span class="c">     * @deprecated Use elementByAxis</span>
<span class="c">     * @param {HTMLElement} element The html element.</span>
<span class="c">     * @param {Function} fn optional An optional boolean test to apply.</span>
<span class="c">     * The optional function is passed the current DOM node being tested as its only argument.</span>
<span class="c">     * If no function is given, the first sibling is returned.</span>
<span class="c">     * @param {Boolean} all optional Whether all node types should be scanned, or just element nodes.</span>
<span class="c">     * @return {HTMLElement | null} The matching DOM node or null if none found. </span>
<span class="c">     */</span>
    <span class="nx">next</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">all</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">elementByAxis</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">NEXT_SIBLING</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">all</span><span class="o">);</span>
    <span class="o">},</span>

    <span class="c">/*</span>
<span class="c">     * Finds the ancestor of the element.</span>
<span class="c">     * @method ancestor</span>
<span class="c">     * @deprecated Use elementByAxis</span>
<span class="c">     * @param {HTMLElement} element The html element.</span>
<span class="c">     * @param {Function} fn optional An optional boolean test to apply.</span>
<span class="c">     * The optional function is passed the current DOM node being tested as its only argument.</span>
<span class="c">     * If no function is given, the parentNode is returned.</span>
<span class="c">     * @param {Boolean} all optional Whether all node types should be scanned, or just element nodes.</span>
<span class="c">     * @return {HTMLElement | null} The matching DOM node or null if none found. </span>
<span class="c">     */</span>
     <span class="c">// TODO: optional stopAt node?</span>
<span class="c"></span>    <span class="nx">ancestor</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">all</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">elementByAxis</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">PARENT_NODE</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">all</span><span class="o">);</span>
    <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * Searches the element by the given axis for the first matching element.</span>
<span class="c">     * @method elementByAxis</span>
<span class="c">     * @param {HTMLElement} element The html element.</span>
<span class="c">     * @param {String} axis The axis to search (parentNode, nextSibling, previousSibling).</span>
<span class="c">     * @param {Function} fn optional An optional boolean test to apply.</span>
<span class="c">     * @param {Boolean} all optional Whether all node types should be returned, or just element nodes.</span>
<span class="c">     * The optional function is passed the current HTMLElement being tested as its only argument.</span>
<span class="c">     * If no function is given, the first element is returned.</span>
<span class="c">     * @return {HTMLElement | null} The matching element or null if none found.</span>
<span class="c">     */</span>
    <span class="nx">elementByAxis</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">axis</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">all</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">while</span> <span class="o">(</span><span class="nx">element</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">element</span> <span class="o">=</span> <span class="nx">element</span><span class="o">[</span><span class="nx">axis</span><span class="o">]))</span> <span class="o">{</span> <span class="c">// NOTE: assignment</span>
<span class="c"></span>                <span class="k">if</span> <span class="o">(</span> <span class="o">(</span><span class="nx">all</span> <span class="o">||</span> <span class="nx">element</span><span class="o">[</span><span class="nx">TAG_NAME</span><span class="o">])</span> <span class="o">&amp;&amp;</span> <span class="o">(!</span><span class="nx">fn</span> <span class="o">||</span> <span class="nx">fn</span><span class="o">(</span><span class="nx">element</span><span class="o">))</span> <span class="o">)</span> <span class="o">{</span>
                    <span class="k">return</span> <span class="nx">element</span><span class="o">;</span>
                <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="c">/*</span>
<span class="c">     * Finds all elements with the given tag.</span>
<span class="c">     * @method byTag</span>
<span class="c">     * @deprecated Use Selector</span>
<span class="c">     * @param {String} tag The tag being search for. </span>
<span class="c">     * @param {HTMLElement} root optional An optional root element to start from.</span>
<span class="c">     * @param {Function} fn optional An optional boolean test to apply.</span>
<span class="c">     * The optional function is passed the current HTMLElement being tested as its only argument.</span>
<span class="c">     * If no function is given, all elements with the given tag are returned.</span>
<span class="c">     * @return {Array} The collection of matching elements.</span>
<span class="c">     */</span>
    <span class="nx">byTag</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">tag</span><span class="o">,</span> <span class="nx">root</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">root</span> <span class="o">=</span> <span class="nx">root</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">doc</span><span class="o">;</span>

        <span class="k">var</span> <span class="nx">elements</span> <span class="o">=</span> <span class="nx">root</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="nx">tag</span><span class="o">),</span>
            <span class="nx">retNodes</span> <span class="o">=</span> <span class="o">[],</span>
            <span class="nx">i</span><span class="o">,</span> <span class="nx">len</span><span class="o">;</span>

        <span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">,</span> <span class="nx">len</span> <span class="o">=</span> <span class="nx">elements</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span> <span class="o">!</span><span class="nx">fn</span> <span class="o">||</span> <span class="nx">fn</span><span class="o">(</span><span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">])</span> <span class="o">)</span> <span class="o">{</span>
                <span class="nx">retNodes</span><span class="o">[</span><span class="nx">retNodes</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">return</span> <span class="nx">retNodes</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="c">/*</span>
<span class="c">     * Finds the first element with the given tag.</span>
<span class="c">     * @method firstByTag</span>
<span class="c">     * @deprecated Use Selector</span>
<span class="c">     * @param {String} tag The tag being search for. </span>
<span class="c">     * @param {HTMLElement} root optional An optional root element to start from.</span>
<span class="c">     * @param {Function} fn optional An optional boolean test to apply.</span>
<span class="c">     * The optional function is passed the current HTMLElement being tested as its only argument.</span>
<span class="c">     * If no function is given, the first match is returned. </span>
<span class="c">     * @return {HTMLElement} The matching element.</span>
<span class="c">     */</span>
    <span class="nx">firstByTag</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">tag</span><span class="o">,</span> <span class="nx">root</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">root</span> <span class="o">=</span> <span class="nx">root</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">doc</span><span class="o">;</span>

        <span class="k">var</span> <span class="nx">elements</span> <span class="o">=</span> <span class="nx">root</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="nx">tag</span><span class="o">),</span>
            <span class="nx">ret</span> <span class="o">=</span> <span class="kc">null</span><span class="o">,</span>
            <span class="nx">i</span><span class="o">,</span> <span class="nx">len</span><span class="o">;</span>

        <span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">,</span> <span class="nx">len</span> <span class="o">=</span> <span class="nx">elements</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span> <span class="o">!</span><span class="nx">fn</span> <span class="o">||</span> <span class="nx">fn</span><span class="o">(</span><span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">])</span> <span class="o">)</span> <span class="o">{</span>
                <span class="nx">ret</span> <span class="o">=</span> <span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">return</span> <span class="nx">ret</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="c">/*</span>
<span class="c">     * Filters a collection of HTMLElements by the given attributes.</span>
<span class="c">     * @method filterElementsBy</span>
<span class="c">     * @param {Array} elements The collection of HTMLElements to filter.</span>
<span class="c">     * @param {Function} fn A boolean test to apply.</span>
<span class="c">     * The function is passed the current HTMLElement being tested as its only argument.</span>
<span class="c">     * If no function is given, all HTMLElements are kept.</span>
<span class="c">     * @return {Array} The filtered collection of HTMLElements.</span>
<span class="c">     */</span>
    <span class="nx">filterElementsBy</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">elements</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">firstOnly</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">ret</span> <span class="o">=</span> <span class="o">(</span><span class="nx">firstOnly</span><span class="o">)</span> <span class="o">?</span> <span class="kc">null</span> <span class="o">:</span> <span class="o">[],</span>
            <span class="nx">i</span><span class="o">,</span> <span class="nx">len</span><span class="o">;</span>
        <span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">,</span> <span class="nx">len</span> <span class="o">=</span> <span class="nx">elements</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">][</span><span class="nx">TAG_NAME</span><span class="o">]</span> <span class="o">&amp;&amp;</span> <span class="o">(!</span><span class="nx">fn</span> <span class="o">||</span> <span class="nx">fn</span><span class="o">(</span><span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">])))</span> <span class="o">{</span>
                <span class="k">if</span> <span class="o">(</span><span class="nx">firstOnly</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">ret</span> <span class="o">=</span> <span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">ret</span><span class="o">[</span><span class="nx">ret</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="k">return</span> <span class="nx">ret</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * Determines whether or not one HTMLElement is or contains another HTMLElement.</span>
<span class="c">     * @method contains</span>
<span class="c">     * @param {HTMLElement} element The containing html element.</span>
<span class="c">     * @param {HTMLElement} needle The html element that may be contained.</span>
<span class="c">     * @return {Boolean} Whether or not the element is or contains the needle.</span>
<span class="c">     */</span>
    <span class="nx">contains</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">needle</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">ret</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

        <span class="k">if</span> <span class="o">(</span> <span class="o">!</span><span class="nx">needle</span> <span class="o">||</span> <span class="o">!</span><span class="nx">element</span> <span class="o">||</span> <span class="o">!</span><span class="nx">needle</span><span class="o">[</span><span class="nx">NODE_TYPE</span><span class="o">]</span> <span class="o">||</span> <span class="o">!</span><span class="nx">element</span><span class="o">[</span><span class="nx">NODE_TYPE</span><span class="o">])</span> <span class="o">{</span>
            <span class="nx">ret</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        <span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">element</span><span class="o">[</span><span class="nx">CONTAINS</span><span class="o">])</span>  <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">.</span><span class="nx">opera</span> <span class="o">||</span> <span class="nx">needle</span><span class="o">[</span><span class="nx">NODE_TYPE</span><span class="o">]</span> <span class="o">===</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span> <span class="c">// IE &amp; SAF contains fail if needle not an ELEMENT_NODE</span>
<span class="c"></span>                <span class="nx">ret</span> <span class="o">=</span> <span class="nx">element</span><span class="o">[</span><span class="nx">CONTAINS</span><span class="o">](</span><span class="nx">needle</span><span class="o">);</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                <span class="nx">ret</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_bruteContains</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">needle</span><span class="o">);</span> 
            <span class="o">}</span>
        <span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">element</span><span class="o">[</span><span class="nx">COMPARE_DOCUMENT_POSITION</span><span class="o">])</span> <span class="o">{</span> <span class="c">// gecko</span>
<span class="c"></span>            <span class="k">if</span> <span class="o">(</span><span class="nx">element</span> <span class="o">===</span> <span class="nx">needle</span> <span class="o">||</span> <span class="o">!!(</span><span class="nx">element</span><span class="o">[</span><span class="nx">COMPARE_DOCUMENT_POSITION</span><span class="o">](</span><span class="nx">needle</span><span class="o">)</span> <span class="o">&amp;</span> <span class="m">16</span><span class="o">))</span> <span class="o">{</span> 
                <span class="nx">ret</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="k">return</span> <span class="nx">ret</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * Determines whether or not the HTMLElement is part of the document.</span>
<span class="c">     * @method inDoc</span>
<span class="c">     * @param {HTMLElement} element The containing html element.</span>
<span class="c">     * @param {HTMLElement} doc optional The document to check.</span>
<span class="c">     * @return {Boolean} Whether or not the element is attached to the document. </span>
<span class="c">     */</span>
    <span class="nx">inDoc</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">doc</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">doc</span> <span class="o">=</span> <span class="nx">doc</span> <span class="o">||</span> <span class="nx">element</span><span class="o">[</span><span class="nx">OWNER_DOCUMENT</span><span class="o">];</span>
        <span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
        <span class="k">if</span> <span class="o">(!</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span> <span class="c">// TODO: remove when done?</span>
<span class="c"></span>            <span class="nx">id</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">guid</span><span class="o">();</span>
        <span class="o">}</span>

        <span class="k">return</span> <span class="o">!!</span> <span class="o">(</span><span class="nx">doc</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="nx">id</span><span class="o">));</span>
    <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * Inserts the new node as the previous sibling of the reference node </span>
<span class="c">     * @method insertBefore</span>
<span class="c">     * @param {String | HTMLElement} newNode The node to be inserted</span>
<span class="c">     * @param {String | HTMLElement} referenceNode The node to insert the new node before </span>
<span class="c">     * @return {HTMLElement} The node that was inserted (or null if insert fails) </span>
<span class="c">     */</span>
    <span class="nx">insertBefore</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">newNode</span><span class="o">,</span> <span class="nx">referenceNode</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">ret</span> <span class="o">=</span> <span class="kc">null</span><span class="o">,</span>
            <span class="nx">parent</span><span class="o">;</span>
        <span class="k">if</span> <span class="o">(</span><span class="nx">newNode</span> <span class="o">&amp;&amp;</span> <span class="nx">referenceNode</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">parent</span> <span class="o">=</span> <span class="nx">referenceNode</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">))</span> <span class="o">{</span> <span class="c">// NOTE: assignment</span>
<span class="c"></span>            <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">newNode</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">newNode</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">create</span><span class="o">(</span><span class="nx">newNode</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="nx">ret</span> <span class="o">=</span> <span class="nx">parent</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">newNode</span><span class="o">,</span> <span class="nx">referenceNode</span><span class="o">);</span>
        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
            <span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;insertBefore failed: missing or invalid arg(s)&#39;</span><span class="o">,</span> <span class="s1">&#39;error&#39;</span><span class="o">,</span> <span class="s1">&#39;dom&#39;</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">return</span> <span class="nx">ret</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * Inserts the new node as the next sibling of the reference node </span>
<span class="c">     * @method insertAfter</span>
<span class="c">     * @param {String | HTMLElement} newNode The node to be inserted</span>
<span class="c">     * @param {String | HTMLElement} referenceNode The node to insert the new node after </span>
<span class="c">     * @return {HTMLElement} The node that was inserted (or null if insert fails) </span>
<span class="c">     */</span>
    <span class="nx">insertAfter</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">newNode</span><span class="o">,</span> <span class="nx">referenceNode</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span> <span class="o">(!</span><span class="nx">newNode</span> <span class="o">||</span> <span class="o">!</span><span class="nx">referenceNode</span> <span class="o">||</span> <span class="o">!</span><span class="nx">referenceNode</span><span class="o">[</span><span class="nx">PARENT_NODE</span><span class="o">])</span> <span class="o">{</span>
            <span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;insertAfter failed: missing or invalid arg(s)&#39;</span><span class="o">,</span> <span class="s1">&#39;error&#39;</span><span class="o">,</span> <span class="s1">&#39;DOM&#39;</span><span class="o">);</span>
            <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
        <span class="o">}</span>       

        <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">newNode</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">newNode</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">create</span><span class="o">(</span><span class="nx">newNode</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">referenceNode</span><span class="o">[</span><span class="nx">NEXT_SIBLING</span><span class="o">])</span> <span class="o">{</span>
            <span class="k">return</span> <span class="nx">referenceNode</span><span class="o">[</span><span class="nx">PARENT_NODE</span><span class="o">].</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">newNode</span><span class="o">,</span> <span class="nx">referenceNode</span><span class="o">[</span><span class="nx">NEXT_SIBLING</span><span class="o">]);</span> 
        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
            <span class="k">return</span> <span class="nx">referenceNode</span><span class="o">[</span><span class="nx">PARENT_NODE</span><span class="o">].</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">newNode</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * Creates a new dom node using the provided markup string. </span>
<span class="c">     * @method create</span>
<span class="c">     * @param {String} html The markup used to create the element</span>
<span class="c">     * @param {HTMLDocument} doc An optional document context </span>
<span class="c">     */</span>
    <span class="nx">create</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">html</span><span class="o">,</span> <span class="nx">doc</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">html</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">trim</span><span class="o">(</span><span class="nx">html</span><span class="o">);</span> <span class="c">// match IE which trims whitespace from innerHTML</span>
<span class="c"></span>        <span class="k">if</span> <span class="o">(!</span><span class="nx">doc</span> <span class="o">&amp;&amp;</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_cloneCache</span><span class="o">[</span><span class="nx">html</span><span class="o">])</span> <span class="o">{</span>
            <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_cloneCache</span><span class="o">[</span><span class="nx">html</span><span class="o">].</span><span class="nx">cloneNode</span><span class="o">(</span><span class="kc">true</span><span class="o">);</span> <span class="c">// NOTE: return</span>
<span class="c"></span>        <span class="o">}</span>

        <span class="nx">doc</span> <span class="o">=</span> <span class="nx">doc</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">doc</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="nx">re_tag</span><span class="o">.</span><span class="nx">exec</span><span class="o">(</span><span class="nx">html</span><span class="o">),</span>
            <span class="nx">create</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_create</span><span class="o">,</span>
            <span class="nx">custom</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">creators</span><span class="o">,</span>
            <span class="nx">ret</span> <span class="o">=</span> <span class="kc">null</span><span class="o">,</span>
            <span class="nx">tag</span><span class="o">,</span> <span class="nx">nodes</span><span class="o">;</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">m</span> <span class="o">&amp;&amp;</span> <span class="nx">custom</span><span class="o">[</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">]])</span> <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">custom</span><span class="o">[</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">]]</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">create</span> <span class="o">=</span> <span class="nx">custom</span><span class="o">[</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">]];</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                <span class="nx">tag</span> <span class="o">=</span> <span class="nx">custom</span><span class="o">[</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">]];</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="nx">nodes</span> <span class="o">=</span> <span class="nx">create</span><span class="o">(</span><span class="nx">html</span><span class="o">,</span> <span class="nx">doc</span><span class="o">,</span> <span class="nx">tag</span><span class="o">).</span><span class="nx">childNodes</span><span class="o">;</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">nodes</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span> <span class="c">// return single node, breaking parentNode ref from &quot;fragment&quot;</span>
<span class="c"></span>            <span class="nx">ret</span> <span class="o">=</span> <span class="nx">nodes</span><span class="o">[</span><span class="m">0</span><span class="o">].</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">nodes</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span>
        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span> <span class="c">// return multiple nodes as a fragment</span>
<span class="c"></span>            <span class="nx">ret</span> <span class="o">=</span> <span class="nx">doc</span><span class="o">.</span><span class="nx">createDocumentFragment</span><span class="o">();</span>
            <span class="k">while</span> <span class="o">(</span><span class="nx">nodes</span><span class="o">.</span><span class="nx">length</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">ret</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">nodes</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span> 
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_cloneCache</span><span class="o">[</span><span class="nx">html</span><span class="o">]</span> <span class="o">=</span> <span class="nx">ret</span><span class="o">.</span><span class="nx">cloneNode</span><span class="o">(</span><span class="kc">true</span><span class="o">);</span>
        <span class="k">return</span> <span class="nx">ret</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="nx">CUSTOM_ATTRIBUTES</span><span class="o">:</span> <span class="o">(!</span><span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">hasAttribute</span><span class="o">)</span> <span class="o">?</span> <span class="o">{</span> <span class="c">// IE &lt; 8</span>
<span class="c"></span>        <span class="s1">&#39;for&#39;</span><span class="o">:</span> <span class="s1">&#39;htmlFor&#39;</span><span class="o">,</span>
        <span class="s1">&#39;class&#39;</span><span class="o">:</span> <span class="s1">&#39;className&#39;</span>
    <span class="o">}</span> <span class="o">:</span> <span class="o">{</span> <span class="c">// w3c</span>
<span class="c"></span>        <span class="s1">&#39;htmlFor&#39;</span><span class="o">:</span> <span class="s1">&#39;for&#39;</span><span class="o">,</span>
        <span class="s1">&#39;className&#39;</span><span class="o">:</span> <span class="s1">&#39;class&#39;</span>
    <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * Provides a normalized attribute interface. </span>
<span class="c">     * @method setAttibute</span>
<span class="c">     * @param {String | HTMLElement} el The target element for the attribute.</span>
<span class="c">     * @param {String} attr The attribute to set.</span>
<span class="c">     * @param {String} val The value of the attribute.</span>
<span class="c">     */</span>
    <span class="nx">setAttribute</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">attr</span><span class="o">,</span> <span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span> <span class="o">(</span><span class="nx">el</span> <span class="o">&amp;&amp;</span> <span class="nx">el</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">attr</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">CUSTOM_ATTRIBUTES</span><span class="o">[</span><span class="nx">attr</span><span class="o">]</span> <span class="o">||</span> <span class="nx">attr</span><span class="o">;</span>
            <span class="nx">el</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="nx">attr</span><span class="o">,</span> <span class="nx">val</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">},</span>


    <span class="c">/**</span>
<span class="c">     * Provides a normalized attribute interface. </span>
<span class="c">     * @method getAttibute</span>
<span class="c">     * @param {String | HTMLElement} el The target element for the attribute.</span>
<span class="c">     * @param {String} attr The attribute to get.</span>
<span class="c">     * @return {String} The current value of the attribute. </span>
<span class="c">     */</span>
    <span class="nx">getAttribute</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">attr</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">ret</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
        <span class="k">if</span> <span class="o">(</span><span class="nx">el</span> <span class="o">&amp;&amp;</span> <span class="nx">el</span><span class="o">.</span><span class="nx">getAttribute</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">attr</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">CUSTOM_ATTRIBUTES</span><span class="o">[</span><span class="nx">attr</span><span class="o">]</span> <span class="o">||</span> <span class="nx">attr</span><span class="o">;</span>
            <span class="nx">ret</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">getAttribute</span><span class="o">(</span><span class="nx">attr</span><span class="o">,</span> <span class="m">2</span><span class="o">);</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">ret</span> <span class="o">===</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">ret</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">;</span> <span class="c">// per DOM spec</span>
<span class="c"></span>            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">return</span> <span class="nx">ret</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="c">// @deprecated</span>
<span class="c"></span>    <span class="nx">srcIndex</span><span class="o">:</span> <span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">sourceIndex</span><span class="o">)</span> <span class="o">?</span>
        <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="o">(</span><span class="nx">node</span> <span class="o">&amp;&amp;</span> <span class="nx">node</span><span class="o">.</span><span class="nx">sourceIndex</span><span class="o">)</span> <span class="o">?</span> <span class="nx">node</span><span class="o">.</span><span class="nx">sourceIndex</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
        <span class="o">}</span> <span class="o">:</span>
        <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="o">(</span><span class="nx">node</span> <span class="o">&amp;&amp;</span> <span class="nx">node</span><span class="o">[</span><span class="nx">OWNER_DOCUMENT</span><span class="o">])</span> <span class="o">?</span> 
                    <span class="o">[].</span><span class="nx">indexOf</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">node</span><span class="o">[</span><span class="nx">OWNER_DOCUMENT</span><span class="o">].</span>
                            <span class="nx">getElementsByTagName</span><span class="o">(</span><span class="s1">&#39;*&#39;</span><span class="o">),</span> <span class="nx">node</span><span class="o">)</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
        <span class="o">},</span>

    <span class="nx">isWindow</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span> <span class="nx">obj</span><span class="o">.</span><span class="nx">alert</span> <span class="o">&amp;&amp;</span> <span class="nx">obj</span><span class="o">.</span><span class="nb">document</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="nx">_fragClones</span><span class="o">:</span> <span class="o">{</span>
        <span class="nx">div</span><span class="o">:</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s1">&#39;div&#39;</span><span class="o">)</span>
    <span class="o">},</span>

    <span class="nx">_create</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">html</span><span class="o">,</span> <span class="nx">doc</span><span class="o">,</span> <span class="nx">tag</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">tag</span> <span class="o">=</span> <span class="nx">tag</span> <span class="o">||</span> <span class="s1">&#39;div&#39;</span><span class="o">;</span>

        <span class="k">var</span> <span class="nx">frag</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_fragClones</span><span class="o">[</span><span class="nx">tag</span><span class="o">];</span>
        <span class="k">if</span> <span class="o">(</span><span class="nx">frag</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">frag</span> <span class="o">=</span> <span class="nx">frag</span><span class="o">.</span><span class="nx">cloneNode</span><span class="o">(</span><span class="kc">false</span><span class="o">);</span>
        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
            <span class="nx">frag</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_fragClones</span><span class="o">[</span><span class="nx">tag</span><span class="o">]</span> <span class="o">=</span> <span class="nx">doc</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="nx">tag</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="nx">frag</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">html</span><span class="o">;</span>
        <span class="k">return</span> <span class="nx">frag</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="nx">_removeChildNodes</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">while</span> <span class="o">(</span><span class="nx">node</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">node</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">node</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">},</span>

    <span class="nx">_cloneCache</span><span class="o">:</span> <span class="o">{},</span>

    <span class="c">/**</span>
<span class="c">     * Inserts content in a node at the given location </span>
<span class="c">     * @method addHTML</span>
<span class="c">     * @param {HTMLElement} node The node to insert into</span>
<span class="c">     * @param {String} content The content to be inserted </span>
<span class="c">     * @param {String} where Where to insert the content; default is after lastChild </span>
<span class="c">     */</span>
    <span class="nx">addHTML</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">,</span> <span class="nx">content</span><span class="o">,</span> <span class="nx">where</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">content</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">content</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">trim</span><span class="o">(</span><span class="nx">content</span><span class="o">);</span> <span class="c">// match IE which trims whitespace from innerHTML</span>
<span class="c"></span>        <span class="o">}</span>

        <span class="k">var</span> <span class="nx">newNode</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_cloneCache</span><span class="o">[</span><span class="nx">content</span><span class="o">];</span>
            
        <span class="k">if</span> <span class="o">(</span><span class="nx">newNode</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">newNode</span> <span class="o">=</span> <span class="nx">newNode</span><span class="o">.</span><span class="nx">cloneNode</span><span class="o">(</span><span class="kc">true</span><span class="o">);</span>
        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">content</span><span class="o">.</span><span class="nx">nodeType</span><span class="o">)</span> <span class="o">{</span> <span class="c">// domNode</span>
<span class="c"></span>                <span class="nx">newNode</span> <span class="o">=</span> <span class="nx">content</span><span class="o">;</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span> <span class="c">// create from string and cache</span>
<span class="c"></span>                <span class="nx">newNode</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">create</span><span class="o">(</span><span class="nx">content</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">where</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">where</span><span class="o">.</span><span class="nx">nodeType</span><span class="o">)</span> <span class="o">{</span> <span class="c">// insert regardless of relationship to node</span>
<span class="c"></span>                <span class="c">// TODO: check if node.contains(where)?</span>
<span class="c"></span>                <span class="nx">where</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">newNode</span><span class="o">,</span> <span class="nx">where</span><span class="o">);</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                <span class="nx">switch</span> <span class="o">(</span><span class="nx">where</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">case</span> <span class="s1">&#39;replace&#39;</span><span class="o">:</span>
                        <span class="k">while</span> <span class="o">(</span><span class="nx">node</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">)</span> <span class="o">{</span>
                            <span class="nx">node</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">node</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">);</span>
                        <span class="o">}</span>
                        <span class="nx">node</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">newNode</span><span class="o">);</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s1">&#39;before&#39;</span><span class="o">:</span>
                        <span class="nx">node</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">newNode</span><span class="o">,</span> <span class="nx">node</span><span class="o">);</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s1">&#39;after&#39;</span><span class="o">:</span>
                        <span class="k">if</span> <span class="o">(</span><span class="nx">node</span><span class="o">.</span><span class="nx">nextSibling</span><span class="o">)</span> <span class="o">{</span> <span class="c">// IE errors if refNode is null</span>
<span class="c"></span>                            <span class="nx">node</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">newNode</span><span class="o">,</span> <span class="nx">node</span><span class="o">.</span><span class="nx">nextSibling</span><span class="o">);</span>
                        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                            <span class="nx">node</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">newNode</span><span class="o">);</span>
                        <span class="o">}</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">default</span><span class="o">:</span>
                        <span class="nx">node</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">newNode</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
            <span class="nx">node</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">newNode</span><span class="o">);</span>
        <span class="o">}</span>

        <span class="k">return</span> <span class="nx">newNode</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="nx">VALUE_SETTERS</span><span class="o">:</span> <span class="o">{},</span>

    <span class="nx">VALUE_GETTERS</span><span class="o">:</span> <span class="o">{},</span>

    <span class="nx">getValue</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">ret</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">,</span> <span class="c">// TODO: return null?</span>
<span class="c"></span>            <span class="nx">getter</span><span class="o">;</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">node</span> <span class="o">&amp;&amp;</span> <span class="nx">node</span><span class="o">[</span><span class="nx">TAG_NAME</span><span class="o">])</span> <span class="o">{</span>
            <span class="nx">getter</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">VALUE_GETTERS</span><span class="o">[</span><span class="nx">node</span><span class="o">[</span><span class="nx">TAG_NAME</span><span class="o">].</span><span class="nx">toLowerCase</span><span class="o">()];</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">getter</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">ret</span> <span class="o">=</span> <span class="nx">getter</span><span class="o">(</span><span class="nx">node</span><span class="o">);</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                <span class="nx">ret</span> <span class="o">=</span> <span class="nx">node</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="k">return</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">ret</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="o">)</span> <span class="o">?</span> <span class="nx">ret</span> <span class="o">:</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="nx">setValue</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">,</span> <span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">setter</span><span class="o">;</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">node</span> <span class="o">&amp;&amp;</span> <span class="nx">node</span><span class="o">[</span><span class="nx">TAG_NAME</span><span class="o">])</span> <span class="o">{</span>
            <span class="nx">setter</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">VALUE_SETTERS</span><span class="o">[</span><span class="nx">node</span><span class="o">[</span><span class="nx">TAG_NAME</span><span class="o">].</span><span class="nx">toLowerCase</span><span class="o">()];</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">setter</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">setter</span><span class="o">(</span><span class="nx">node</span><span class="o">,</span> <span class="nx">val</span><span class="o">);</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                <span class="nx">node</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">val</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">},</span>

    <span class="nx">_stripScripts</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">scripts</span> <span class="o">=</span> <span class="nx">node</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="s1">&#39;script&#39;</span><span class="o">),</span>
            <span class="nx">i</span><span class="o">,</span> <span class="nx">script</span><span class="o">;</span>

        <span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">,</span> <span class="nx">script</span><span class="o">;</span> <span class="nx">script</span> <span class="o">=</span> <span class="nx">scripts</span><span class="o">[</span><span class="nx">i</span><span class="o">++];)</span> <span class="o">{</span>
            <span class="nx">script</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">script</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">},</span>

    <span class="nx">_execScripts</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">scripts</span><span class="o">,</span> <span class="nx">startIndex</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">newScript</span><span class="o">,</span>
            <span class="nx">i</span><span class="o">,</span> <span class="nx">script</span><span class="o">;</span>

        <span class="nx">startIndex</span> <span class="o">=</span> <span class="nx">startIndex</span> <span class="o">||</span> <span class="m">0</span><span class="o">;</span>

        <span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">startIndex</span><span class="o">,</span> <span class="nx">script</span><span class="o">;</span> <span class="nx">script</span> <span class="o">=</span> <span class="nx">scripts</span><span class="o">[</span><span class="nx">i</span><span class="o">++];)</span> <span class="o">{</span>
            <span class="nx">newScript</span> <span class="o">=</span> <span class="nx">script</span><span class="o">.</span><span class="nx">ownerDocument</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s1">&#39;script&#39;</span><span class="o">);</span>
            <span class="nx">script</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">replaceChild</span><span class="o">(</span><span class="nx">newScript</span><span class="o">,</span> <span class="nx">script</span><span class="o">);</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">script</span><span class="o">.</span><span class="nx">text</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">newScript</span><span class="o">.</span><span class="nx">text</span> <span class="o">=</span> <span class="nx">script</span><span class="o">.</span><span class="nx">text</span><span class="o">;</span>
            <span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">script</span><span class="o">.</span><span class="nx">src</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">newScript</span><span class="o">.</span><span class="nx">src</span> <span class="o">=</span> <span class="nx">script</span><span class="o">.</span><span class="nx">src</span><span class="o">;</span>

                 <span class="c">// &quot;pause&quot; while loading to ensure exec order </span>
<span class="c"></span>                <span class="c">// FF reports typeof onload as &quot;undefined&quot;, so try IE first</span>
<span class="c"></span>                <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">newScript</span><span class="o">.</span><span class="nx">onreadystatechange</span> <span class="o">!==</span> <span class="s1">&#39;undefined&#39;</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">newScript</span><span class="o">.</span><span class="nx">onreadystatechange</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
                        <span class="k">if</span> <span class="o">(</span><span class="sr">/loaded|complete/</span><span class="o">.</span><span class="nx">test</span><span class="o">(</span><span class="nx">script</span><span class="o">.</span><span class="nx">readyState</span><span class="o">))</span> <span class="o">{</span>
                            <span class="nx">event</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">.</span><span class="nx">onreadystatechange</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span> 
                            <span class="c">// timer to help ensure exec order</span>
<span class="c"></span>                            <span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span>
                                <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_execScripts</span><span class="o">(</span><span class="nx">scripts</span><span class="o">,</span> <span class="nx">i</span><span class="o">++);</span>
                            <span class="o">},</span> <span class="m">0</span><span class="o">);</span>
                        <span class="o">}</span>
                    <span class="o">};</span>
                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">newScript</span><span class="o">.</span><span class="nx">onload</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">e</span><span class="o">.</span><span class="nx">target</span><span class="o">.</span><span class="nx">onload</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span> 
                        <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_execScripts</span><span class="o">(</span><span class="nx">scripts</span><span class="o">,</span> <span class="nx">i</span><span class="o">++);</span>
                    <span class="o">};</span>
                <span class="o">}</span>
                <span class="k">return</span><span class="o">;</span> <span class="c">// NOTE: early return to chain async loading</span>
<span class="c"></span>            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * Brute force version of contains.</span>
<span class="c">     * Used for browsers without contains support for non-HTMLElement Nodes (textNodes, etc).</span>
<span class="c">     * @method _bruteContains</span>
<span class="c">     * @private</span>
<span class="c">     * @param {HTMLElement} element The containing html element.</span>
<span class="c">     * @param {HTMLElement} needle The html element that may be contained.</span>
<span class="c">     * @return {Boolean} Whether or not the element is or contains the needle.</span>
<span class="c">     */</span>
    <span class="nx">_bruteContains</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">needle</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">while</span> <span class="o">(</span><span class="nx">needle</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">element</span> <span class="o">===</span> <span class="nx">needle</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="nx">needle</span> <span class="o">=</span> <span class="nx">needle</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
    <span class="o">},</span>

<span class="c">// TODO: move to Lang?</span>
<span class="c"></span>    <span class="c">/**</span>
<span class="c">     * Memoizes dynamic regular expressions to boost runtime performance. </span>
<span class="c">     * @method _getRegExp</span>
<span class="c">     * @private</span>
<span class="c">     * @param {String} str The string to convert to a regular expression.</span>
<span class="c">     * @param {String} flags optional An optinal string of flags.</span>
<span class="c">     * @return {RegExp} An instance of RegExp</span>
<span class="c">     */</span>
    <span class="nx">_getRegExp</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">str</span><span class="o">,</span> <span class="nx">flags</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">flags</span> <span class="o">=</span> <span class="nx">flags</span> <span class="o">||</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
        <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_regexCache</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_regexCache</span> <span class="o">||</span> <span class="o">{};</span>
        <span class="k">if</span> <span class="o">(!</span><span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_regexCache</span><span class="o">[</span><span class="nx">str</span> <span class="o">+</span> <span class="nx">flags</span><span class="o">])</span> <span class="o">{</span>
            <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_regexCache</span><span class="o">[</span><span class="nx">str</span> <span class="o">+</span> <span class="nx">flags</span><span class="o">]</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="o">(</span><span class="nx">str</span><span class="o">,</span> <span class="nx">flags</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_regexCache</span><span class="o">[</span><span class="nx">str</span> <span class="o">+</span> <span class="nx">flags</span><span class="o">];</span>
    <span class="o">},</span>

<span class="c">// TODO: make getDoc/Win true privates?</span>
<span class="c"></span>    <span class="c">/**</span>
<span class="c">     * returns the appropriate document.</span>
<span class="c">     * @method _getDoc</span>
<span class="c">     * @private</span>
<span class="c">     * @param {HTMLElement} element optional Target element.</span>
<span class="c">     * @return {Object} The document for the given element or the default document. </span>
<span class="c">     */</span>
    <span class="nx">_getDoc</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">element</span> <span class="o">=</span> <span class="nx">element</span> <span class="o">||</span> <span class="o">{};</span>

        <span class="k">return</span> <span class="o">(</span><span class="nx">element</span><span class="o">[</span><span class="nx">NODE_TYPE</span><span class="o">]</span> <span class="o">===</span> <span class="m">9</span><span class="o">)</span> <span class="o">?</span> <span class="nx">element</span> <span class="o">:</span> <span class="c">// element === document</span>
<span class="c"></span>                <span class="nx">element</span><span class="o">[</span><span class="nx">OWNER_DOCUMENT</span><span class="o">]</span> <span class="o">||</span> <span class="c">// element === DOM node</span>
<span class="c"></span>                <span class="nx">element</span><span class="o">.</span><span class="nb">document</span> <span class="o">||</span> <span class="c">// element === window</span>
<span class="c"></span>                <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">doc</span><span class="o">;</span> <span class="c">// default</span>
<span class="c"></span>    <span class="o">},</span>

    <span class="c">/**</span>
<span class="c">     * returns the appropriate window.</span>
<span class="c">     * @method _getWin</span>
<span class="c">     * @private</span>
<span class="c">     * @param {HTMLElement} element optional Target element.</span>
<span class="c">     * @return {Object} The window for the given element or the default window. </span>
<span class="c">     */</span>
    <span class="nx">_getWin</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">doc</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_getDoc</span><span class="o">(</span><span class="nx">element</span><span class="o">);</span>
        <span class="k">return</span> <span class="nx">doc</span><span class="o">[</span><span class="nx">DEFAULT_VIEW</span><span class="o">]</span> <span class="o">||</span> <span class="nx">doc</span><span class="o">[</span><span class="nx">PARENT_WINDOW</span><span class="o">]</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">win</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="c">// @deprecated, use Selector </span>
<span class="c"></span>    <span class="nx">_childBy</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">rev</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">ret</span> <span class="o">=</span> <span class="kc">null</span><span class="o">,</span>
            <span class="nx">root</span><span class="o">,</span> <span class="nx">axis</span><span class="o">;</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">rev</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">root</span> <span class="o">=</span> <span class="nx">element</span><span class="o">[</span><span class="nx">LAST_CHILD</span><span class="o">];</span>
                <span class="nx">axis</span> <span class="o">=</span> <span class="nx">PREVIOUS_SIBLING</span><span class="o">;</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                <span class="nx">root</span> <span class="o">=</span> <span class="nx">element</span><span class="o">[</span><span class="nx">FIRST_CHILD</span><span class="o">];</span>
                <span class="nx">axis</span> <span class="o">=</span> <span class="nx">NEXT_SIBLING</span><span class="o">;</span>
            <span class="o">}</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">_testElement</span><span class="o">(</span><span class="nx">root</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">fn</span><span class="o">))</span> <span class="o">{</span> <span class="c">// is the matching element</span>
<span class="c"></span>                <span class="nx">ret</span> <span class="o">=</span> <span class="nx">root</span><span class="o">;</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span> <span class="c">// need to scan nextSibling axis of firstChild to find matching element</span>
<span class="c"></span>                <span class="nx">ret</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">elementByAxis</span><span class="o">(</span><span class="nx">root</span><span class="o">,</span> <span class="nx">axis</span><span class="o">,</span> <span class="nx">fn</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">return</span> <span class="nx">ret</span><span class="o">;</span>

    <span class="o">},</span>

    <span class="nx">_batch</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">nodes</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">arg1</span><span class="o">,</span> <span class="nx">arg2</span><span class="o">,</span> <span class="nx">arg3</span><span class="o">,</span> <span class="nx">etc</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">fn</span> <span class="o">=</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">name</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="o">)</span> <span class="o">?</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">[</span><span class="nx">fn</span><span class="o">]</span> <span class="o">:</span> <span class="nx">fn</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">result</span><span class="o">,</span>
            <span class="nx">ret</span> <span class="o">=</span> <span class="o">[];</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">fn</span> <span class="o">&amp;&amp;</span> <span class="nx">nodes</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">Y</span><span class="o">.</span><span class="nx">each</span><span class="o">(</span><span class="nx">nodes</span><span class="o">,</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">if</span> <span class="o">((</span><span class="nx">result</span> <span class="o">=</span> <span class="nx">fn</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">,</span> <span class="nx">node</span><span class="o">,</span> <span class="nx">arg1</span><span class="o">,</span> <span class="nx">arg2</span><span class="o">,</span> <span class="nx">arg3</span><span class="o">,</span> <span class="nx">etc</span><span class="o">))</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">ret</span><span class="o">[</span><span class="nx">ret</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="nx">result</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">});</span>
        <span class="o">}</span>

        <span class="k">return</span> <span class="nx">ret</span><span class="o">.</span><span class="nx">length</span> <span class="o">?</span> <span class="nx">ret</span> <span class="o">:</span> <span class="nx">nodes</span><span class="o">;</span>
    <span class="o">},</span>

    <span class="nx">_testElement</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">tag</span> <span class="o">=</span> <span class="o">(</span><span class="nx">tag</span> <span class="o">&amp;&amp;</span> <span class="nx">tag</span> <span class="o">!==</span> <span class="s1">&#39;*&#39;</span><span class="o">)</span> <span class="o">?</span> <span class="nx">tag</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
        <span class="k">return</span> <span class="o">(</span><span class="nx">element</span> <span class="o">&amp;&amp;</span> <span class="nx">element</span><span class="o">[</span><span class="nx">TAG_NAME</span><span class="o">]</span> <span class="o">&amp;&amp;</span>
                <span class="o">(!</span><span class="nx">tag</span> <span class="o">||</span> <span class="nx">element</span><span class="o">[</span><span class="nx">TAG_NAME</span><span class="o">].</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">===</span> <span class="nx">tag</span><span class="o">)</span> <span class="o">&amp;&amp;</span>
                <span class="o">(!</span><span class="nx">fn</span> <span class="o">||</span> <span class="nx">fn</span><span class="o">(</span><span class="nx">element</span><span class="o">)));</span>
    <span class="o">},</span>

    <span class="nx">creators</span><span class="o">:</span> <span class="o">{},</span>

    <span class="nx">_IESimpleCreate</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">html</span><span class="o">,</span> <span class="nx">doc</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">doc</span> <span class="o">=</span> <span class="nx">doc</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">doc</span><span class="o">;</span>
        <span class="k">return</span> <span class="nx">doc</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="nx">html</span><span class="o">);</span>
    <span class="o">}</span>
<span class="o">};</span>


<span class="o">(</span><span class="k">function</span><span class="o">(</span><span class="nx">Y</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">creators</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">creators</span><span class="o">,</span>
        <span class="nx">create</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">create</span><span class="o">,</span>
        <span class="nx">re_tbody</span> <span class="o">=</span> <span class="sr">/(?:\/(?:thead|tfoot|tbody|caption|col|colgroup)&gt;)+\s*&lt;tbody/</span><span class="o">,</span>

        <span class="nx">TABLE_OPEN</span> <span class="o">=</span> <span class="s1">&#39;&lt;table&gt;&#39;</span><span class="o">,</span>
        <span class="nx">TABLE_CLOSE</span> <span class="o">=</span> <span class="s1">&#39;&lt;/table&gt;&#39;</span><span class="o">;</span>

    <span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">.</span><span class="nx">gecko</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">.</span><span class="nx">ie</span><span class="o">)</span> <span class="o">{</span> <span class="c">// require custom creation code for certain element types</span>
<span class="c"></span>        <span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">creators</span><span class="o">,</span> <span class="o">{</span>
            <span class="nx">option</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">html</span><span class="o">,</span> <span class="nx">doc</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span> <span class="nx">create</span><span class="o">(</span><span class="s1">&#39;&lt;select&gt;&#39;</span> <span class="o">+</span> <span class="nx">html</span> <span class="o">+</span> <span class="s1">&#39;&lt;/select&gt;&#39;</span><span class="o">,</span> <span class="nx">doc</span><span class="o">);</span>
            <span class="o">},</span>

            <span class="nx">tr</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">html</span><span class="o">,</span> <span class="nx">doc</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span> <span class="nx">create</span><span class="o">(</span><span class="s1">&#39;&lt;tbody&gt;&#39;</span> <span class="o">+</span> <span class="nx">html</span> <span class="o">+</span> <span class="s1">&#39;&lt;/tbody&gt;&#39;</span><span class="o">,</span> <span class="nx">doc</span><span class="o">);</span>
            <span class="o">},</span>

            <span class="nx">td</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">html</span><span class="o">,</span> <span class="nx">doc</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span> <span class="nx">create</span><span class="o">(</span><span class="s1">&#39;&lt;tr&gt;&#39;</span> <span class="o">+</span> <span class="nx">html</span> <span class="o">+</span> <span class="s1">&#39;&lt;/tr&gt;&#39;</span><span class="o">,</span> <span class="nx">doc</span><span class="o">);</span>
            <span class="o">},</span> 

            <span class="nx">tbody</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">html</span><span class="o">,</span> <span class="nx">doc</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span> <span class="nx">create</span><span class="o">(</span><span class="nx">TABLE_OPEN</span> <span class="o">+</span> <span class="nx">html</span> <span class="o">+</span> <span class="nx">TABLE_CLOSE</span><span class="o">,</span> <span class="nx">doc</span><span class="o">);</span>
            <span class="o">},</span>

            <span class="nx">legend</span><span class="o">:</span> <span class="s1">&#39;fieldset&#39;</span>
        <span class="o">});</span>

        <span class="nx">creators</span><span class="o">.</span><span class="nx">col</span> <span class="o">=</span> <span class="nx">creators</span><span class="o">.</span><span class="nx">tbody</span><span class="o">;</span> <span class="c">// IE wraps in colgroup</span>
<span class="c"></span>    <span class="o">}</span>

    <span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">.</span><span class="nx">ie</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">creators</span><span class="o">,</span> <span class="o">{</span>
        <span class="c">// TODO: thead/tfoot with nested tbody</span>
<span class="c"></span>            <span class="c">// IE adds TBODY when creating TABLE elements (which may share this impl)</span>
<span class="c"></span>            <span class="nx">tbody</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">html</span><span class="o">,</span> <span class="nx">doc</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">frag</span> <span class="o">=</span> <span class="nx">create</span><span class="o">(</span><span class="nx">TABLE_OPEN</span> <span class="o">+</span> <span class="nx">html</span> <span class="o">+</span> <span class="nx">TABLE_CLOSE</span><span class="o">,</span> <span class="nx">doc</span><span class="o">),</span>
                    <span class="nx">tb</span> <span class="o">=</span> <span class="nx">frag</span><span class="o">.</span><span class="nx">children</span><span class="o">.</span><span class="nx">tags</span><span class="o">(</span><span class="s1">&#39;tbody&#39;</span><span class="o">)[</span><span class="m">0</span><span class="o">];</span>

                <span class="k">if</span> <span class="o">(</span><span class="nx">frag</span><span class="o">.</span><span class="nx">children</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">1</span> <span class="o">&amp;&amp;</span> <span class="nx">tb</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">re_tbody</span><span class="o">.</span><span class="nx">test</span><span class="o">(</span><span class="nx">html</span><span class="o">))</span> <span class="o">{</span>
                    <span class="nx">tb</span><span class="o">[</span><span class="nx">PARENT_NODE</span><span class="o">].</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">tb</span><span class="o">);</span> <span class="c">// strip extraneous tbody</span>
<span class="c"></span>                <span class="o">}</span>
                <span class="k">return</span> <span class="nx">frag</span><span class="o">;</span>
            <span class="o">},</span>

            <span class="nx">script</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">html</span><span class="o">,</span> <span class="nx">doc</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">frag</span> <span class="o">=</span> <span class="nx">doc</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s1">&#39;div&#39;</span><span class="o">);</span>

                <span class="nx">frag</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s1">&#39;-&#39;</span> <span class="o">+</span> <span class="nx">html</span><span class="o">;</span>
                <span class="nx">frag</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">frag</span><span class="o">[</span><span class="nx">FIRST_CHILD</span><span class="o">]);</span>
                <span class="k">return</span> <span class="nx">frag</span><span class="o">;</span>
            <span class="o">}</span>

        <span class="o">},</span> <span class="kc">true</span><span class="o">);</span>

        <span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">VALUE_GETTERS</span><span class="o">,</span> <span class="o">{</span>
            <span class="nx">button</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span> <span class="o">(</span><span class="nx">node</span><span class="o">.</span><span class="nx">attributes</span> <span class="o">&amp;&amp;</span> <span class="nx">node</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">value</span><span class="o">)</span> <span class="o">?</span> <span class="nx">node</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">value</span><span class="o">.</span><span class="nx">value</span> <span class="o">:</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">});</span>

        <span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">VALUE_SETTERS</span><span class="o">,</span> <span class="o">{</span>
            <span class="c">// IE: node.value changes the button text, which should be handled via innerHTML</span>
<span class="c"></span>            <span class="nx">button</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">,</span> <span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">attr</span> <span class="o">=</span> <span class="nx">node</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
                <span class="k">if</span> <span class="o">(!</span><span class="nx">attr</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">attr</span> <span class="o">=</span> <span class="nx">node</span><span class="o">[</span><span class="nx">OWNER_DOCUMENT</span><span class="o">].</span><span class="nx">createAttribute</span><span class="o">(</span><span class="s1">&#39;value&#39;</span><span class="o">);</span>
                    <span class="nx">node</span><span class="o">.</span><span class="nx">setAttributeNode</span><span class="o">(</span><span class="nx">attr</span><span class="o">);</span>
                <span class="o">}</span>

                <span class="nx">attr</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">val</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">});</span>
    <span class="o">}</span>

    <span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">.</span><span class="nx">gecko</span> <span class="o">||</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">.</span><span class="nx">ie</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">creators</span><span class="o">,</span> <span class="o">{</span>
                <span class="nx">th</span><span class="o">:</span> <span class="nx">creators</span><span class="o">.</span><span class="nx">td</span><span class="o">,</span>
                <span class="nx">thead</span><span class="o">:</span> <span class="nx">creators</span><span class="o">.</span><span class="nx">tbody</span><span class="o">,</span>
                <span class="nx">tfoot</span><span class="o">:</span> <span class="nx">creators</span><span class="o">.</span><span class="nx">tbody</span><span class="o">,</span>
                <span class="nx">caption</span><span class="o">:</span> <span class="nx">creators</span><span class="o">.</span><span class="nx">tbody</span><span class="o">,</span>
                <span class="nx">colgroup</span><span class="o">:</span> <span class="nx">creators</span><span class="o">.</span><span class="nx">tbody</span><span class="o">,</span>
                <span class="nx">col</span><span class="o">:</span> <span class="nx">creators</span><span class="o">.</span><span class="nx">tbody</span><span class="o">,</span>
                <span class="nx">optgroup</span><span class="o">:</span> <span class="nx">creators</span><span class="o">.</span><span class="nx">option</span>
        <span class="o">});</span>
    <span class="o">}</span>

    <span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">VALUE_GETTERS</span><span class="o">,</span> <span class="o">{</span>
        <span class="nx">option</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">attrs</span> <span class="o">=</span> <span class="nx">node</span><span class="o">.</span><span class="nx">attributes</span><span class="o">;</span>
            <span class="k">return</span> <span class="o">(</span><span class="nx">attrs</span><span class="o">.</span><span class="nx">value</span> <span class="o">&amp;&amp;</span> <span class="nx">attrs</span><span class="o">.</span><span class="nx">value</span><span class="o">.</span><span class="nx">specified</span><span class="o">)</span> <span class="o">?</span> <span class="nx">node</span><span class="o">.</span><span class="nx">value</span> <span class="o">:</span> <span class="nx">node</span><span class="o">.</span><span class="nx">text</span><span class="o">;</span>
        <span class="o">},</span>

        <span class="nx">select</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">val</span> <span class="o">=</span> <span class="nx">node</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span>
                <span class="nx">options</span> <span class="o">=</span> <span class="nx">node</span><span class="o">.</span><span class="nx">options</span><span class="o">;</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">options</span> <span class="o">&amp;&amp;</span> <span class="nx">val</span> <span class="o">===</span> <span class="s1">&#39;&#39;</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">if</span> <span class="o">(</span><span class="nx">node</span><span class="o">.</span><span class="nx">multiple</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;multiple select normalization not implemented&#39;</span><span class="o">,</span> <span class="s1">&#39;warn&#39;</span><span class="o">,</span> <span class="s1">&#39;DOM&#39;</span><span class="o">);</span>
                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">val</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DOM</span><span class="o">.</span><span class="nx">getValue</span><span class="o">(</span><span class="nx">options</span><span class="o">[</span><span class="nx">node</span><span class="o">.</span><span class="nx">selectedIndex</span><span class="o">],</span> <span class="s1">&#39;value&#39;</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>

            <span class="k">return</span> <span class="nx">val</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">});</span>
<span class="o">})(</span><span class="nx">Y</span><span class="o">);</span>

<span class="o">})(</span><span class="nx">Y</span><span class="o">);</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class=""><a href="module_anim.html" title="anim">anim</a></li>
                                <li class=""><a href="module_attribute.html" title="attribute">attribute</a></li>
                                <li class=""><a href="module_base.html" title="base">base</a></li>
                                <li class=""><a href="module_cache.html" title="cache">cache</a></li>
                                <li class=""><a href="module_classnamemanager.html" title="classnamemanager">classnamemanager</a></li>
                                <li class=""><a href="module_collection.html" title="collection">collection</a></li>
                                <li class=""><a href="module_console.html" title="console">console</a></li>
                                <li class=""><a href="module_console-filters.html" title="console-filters">console-filters</a></li>
                                <li class=""><a href="module_cookie.html" title="cookie">cookie</a></li>
                                <li class=""><a href="module_dataschema.html" title="dataschema">dataschema</a></li>
                                <li class=""><a href="module_datasource.html" title="datasource">datasource</a></li>
                                <li class=""><a href="module_datatype.html" title="datatype">datatype</a></li>
                                <li class=""><a href="module_dd.html" title="dd">dd</a></li>
                                <li class="selected"><a href="module_dom.html" title="dom">dom</a></li>
                                <li class=""><a href="module_dump.html" title="dump">dump</a></li>
                                <li class=""><a href="module_event.html" title="event">event</a></li>
                                <li class=""><a href="module_event-custom.html" title="event-custom">event-custom</a></li>
                                <li class=""><a href="module_event-simulate.html" title="event-simulate">event-simulate</a></li>
                                <li class=""><a href="module_history.html" title="history">history</a></li>
                                <li class=""><a href="module_imageloader.html" title="imageloader">imageloader</a></li>
                                <li class=""><a href="module_io.html" title="io">io</a></li>
                                <li class=""><a href="module_json.html" title="json">json</a></li>
                                <li class=""><a href="module_node.html" title="node">node</a></li>
                                <li class=""><a href="module_node-focusmanager.html" title="node-focusmanager">node-focusmanager</a></li>
                                <li class=""><a href="module_node-menunav.html" title="node-menunav">node-menunav</a></li>
                                <li class=""><a href="module_oop.html" title="oop">oop</a></li>
                                <li class=""><a href="module_overlay.html" title="overlay">overlay</a></li>
                                <li class=""><a href="module_plugin.html" title="plugin">plugin</a></li>
                                <li class=""><a href="module_profiler.html" title="profiler">profiler</a></li>
                                <li class=""><a href="module_queue.html" title="queue">queue</a></li>
                                <li class=""><a href="module_slider.html" title="slider">slider</a></li>
                                <li class=""><a href="module_stylesheet.html" title="stylesheet">stylesheet</a></li>
                                <li class=""><a href="module_substitute.html" title="substitute">substitute</a></li>
                                <li class=""><a href="module_test.html" title="test">test</a></li>
                                <li class=""><a href="module_widget.html" title="widget">widget</a></li>
                                <li class=""><a href="module_widget-position.html" title="widget-position">widget-position</a></li>
                                <li class=""><a href="module_widget-position-ext.html" title="widget-position-ext">widget-position-ext</a></li>
                                <li class=""><a href="module_widget-stack.html" title="widget-stack">widget-stack</a></li>
                                <li class=""><a href="module_widget-stdmod.html" title="widget-stdmod">widget-stdmod</a></li>
                                <li class=""><a href="module_yui.html" title="yui">yui</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="DOM.html" title="DOM">DOM</a></li>
                                <li class=""><a href="Selector.html" title="Selector">Selector</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="color.js.html" title="color.js">color.js</a></li>
                                <li class=""><a href="dom-class.js.html" title="dom-class.js">dom-class.js</a></li>
                                <li class=""><a href="dom-ie-style.js.html" title="dom-ie-style.js">dom-ie-style.js</a></li>
                                <li class=""><a href="dom-region.js.html" title="dom-region.js">dom-region.js</a></li>
                                <li class=""><a href="dom-screen.js.html" title="dom-screen.js">dom-screen.js</a></li>
                                <li class=""><a href="dom-style.js.html" title="dom-style.js">dom-style.js</a></li>
                                <li class="selected"><a href="dom.js.html" title="dom.js">dom.js</a></li>
                                <li class=""><a href="selector-css2.js.html" title="selector-css2.js">selector-css2.js</a></li>
                                <li class=""><a href="selector-css3.js.html" title="selector-css3.js">selector-css3.js</a></li>
                                <li class=""><a href="selector-native.js.html" title="selector-native.js">selector-native.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2009 Yahoo! Inc. All rights reserved.
	</div>
</div>
<script type="text/javascript">
    ALL_YUI_PROPS = [{"access": "", "host": "DOM", "name": "addClass", "url": "DOM.html#method_addClass", "type": "method"}, {"access": "", "host": "DOM", "name": "addHTML", "url": "DOM.html#method_addHTML", "type": "method"}, {"access": "private", "host": "DOM", "name": "_bruteContains", "url": "DOM.html#method__bruteContains", "type": "method"}, {"access": "", "host": "DOM", "name": "byId", "url": "DOM.html#method_byId", "type": "method"}, {"access": "", "host": "DOM", "name": "contains", "url": "DOM.html#method_contains", "type": "method"}, {"access": "", "host": "DOM", "name": "create", "url": "DOM.html#method_create", "type": "method"}, {"access": "", "host": "DOM", "name": "docHeight", "url": "DOM.html#method_docHeight", "type": "method"}, {"access": "", "host": "DOM", "name": "docScrollX", "url": "DOM.html#method_docScrollX", "type": "method"}, {"access": "", "host": "DOM", "name": "docScrollY", "url": "DOM.html#method_docScrollY", "type": "method"}, {"access": "", "host": "DOM", "name": "docWidth", "url": "DOM.html#method_docWidth", "type": "method"}, {"access": "", "host": "DOM", "name": "elementByAxis", "url": "DOM.html#method_elementByAxis", "type": "method"}, {"access": "", "host": "DOM", "name": "getAttibute", "url": "DOM.html#method_getAttibute", "type": "method"}, {"access": "", "host": "DOM", "name": "getComputedStyle", "url": "DOM.html#method_getComputedStyle", "type": "method"}, {"access": "private", "host": "DOM", "name": "_getDoc", "url": "DOM.html#method__getDoc", "type": "method"}, {"access": "private", "host": "DOM", "name": "_getRegExp", "url": "DOM.html#method__getRegExp", "type": "method"}, {"access": "", "host": "DOM", "name": "getStyle", "url": "DOM.html#method_getStyle", "type": "method"}, {"access": "", "host": "DOM", "name": "getText", "url": "DOM.html#method_getText", "type": "method"}, {"access": "private", "host": "DOM", "name": "_getWin", "url": "DOM.html#method__getWin", "type": "method"}, {"access": "", "host": "DOM", "name": "getX", "url": "DOM.html#method_getX", "type": "method"}, {"access": "", "host": "DOM", "name": "getXY", "url": "DOM.html#method_getXY", "type": "method"}, {"access": "", "host": "DOM", "name": "getY", "url": "DOM.html#method_getY", "type": "method"}, {"access": "", "host": "DOM", "name": "hasClass", "url": "DOM.html#method_hasClass", "type": "method"}, {"access": "", "host": "DOM", "name": "inDoc", "url": "DOM.html#method_inDoc", "type": "method"}, {"access": "", "host": "Selector", "name": "inRegion", "url": "Selector.html#method_inRegion", "type": "method"}, {"access": "", "host": "DOM", "name": "insertAfter", "url": "DOM.html#method_insertAfter", "type": "method"}, {"access": "", "host": "DOM", "name": "insertBefore", "url": "DOM.html#method_insertBefore", "type": "method"}, {"access": "", "host": "Selector", "name": "intersect", "url": "Selector.html#method_intersect", "type": "method"}, {"access": "", "host": "Selector", "name": "inViewportRegion", "url": "Selector.html#method_inViewportRegion", "type": "method"}, {"access": "", "host": "Selector", "name": "operators", "url": "Selector.html#property_operators", "type": "property"}, {"access": "", "host": "Selector", "name": "PARENT_NODE", "url": "Selector.html#property_PARENT_NODE", "type": "property"}, {"access": "", "host": "Selector", "name": "query", "url": "Selector.html#method_query", "type": "method"}, {"access": "", "host": "Selector", "name": "region", "url": "Selector.html#method_region", "type": "method"}, {"access": "", "host": "DOM", "name": "removeClass", "url": "DOM.html#method_removeClass", "type": "method"}, {"access": "", "host": "DOM", "name": "replaceClass", "url": "DOM.html#method_replaceClass", "type": "method"}, {"access": "", "host": "DOM", "name": "setAttibute", "url": "DOM.html#method_setAttibute", "type": "method"}, {"access": "", "host": "DOM", "name": "setStyle", "url": "DOM.html#method_setStyle", "type": "method"}, {"access": "", "host": "DOM", "name": "setStyles", "url": "DOM.html#method_setStyles", "type": "method"}, {"access": "", "host": "DOM", "name": "setText", "url": "DOM.html#method_setText", "type": "method"}, {"access": "", "host": "DOM", "name": "setX", "url": "DOM.html#method_setX", "type": "method"}, {"access": "", "host": "DOM", "name": "setXY", "url": "DOM.html#method_setXY", "type": "method"}, {"access": "", "host": "DOM", "name": "setY", "url": "DOM.html#method_setY", "type": "method"}, {"access": "", "host": "Selector", "name": "shorthand", "url": "Selector.html#property_shorthand", "type": "property"}, {"access": "", "host": "DOM", "name": "toggleClass", "url": "DOM.html#method_toggleClass", "type": "method"}, {"access": "", "host": "Selector", "name": "_tokenize", "url": "Selector.html#method__tokenize", "type": "method"}, {"access": "", "host": "Selector", "name": "viewportRegion", "url": "Selector.html#method_viewportRegion", "type": "method"}, {"access": "", "host": "DOM", "name": "winHeight", "url": "DOM.html#method_winHeight", "type": "method"}, {"access": "", "host": "DOM", "name": "winWidth", "url": "DOM.html#method_winWidth", "type": "method"}];
</script>
</body>
</html>
